package process

import (
	"fmt"
	"../../common/message"
	"../model"
)

var onlineUserMap map[int]*message.User = make(map[int]*message.User, 10)
var CurUser model.CurUser

func outputUserOnline() {
	fmt.Println("用户在线列表：")

	for id, _ := range onlineUserMap {
		if id == CurUser.UserId {
			continue
		}

		fmt.Println("在线用户id:\t", id)
	}
}

func updateUserStatus(userStatusNotifyMes *message.UserStatusNotifyMes) {

	user, ok := onlineUserMap[userStatusNotifyMes.UserId]

	if !ok {
		user = &message.User{}
		user.UserId = userStatusNotifyMes.UserId
	}

	user.UserStatus = userStatusNotifyMes.Status
	onlineUserMap[user.UserId] = user

	outputUserOnline()
}